package com.example.controller.stock;

import com.example.pojo.stock.Product_online;
import com.example.pojo.stock.Product_scrap;
import com.example.service.commodity.ScrapService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.ArrayList;
import java.util.List;

/**
 * com.example.controller.stock
 *
 * @author foam
 * create 2020-12-19
 **/
@Controller
@RequestMapping("/scrap")
public class ScrapController {
    @Autowired
    private ScrapService scrapService;

    @RequestMapping("/queryAll")
    public String queryAll(Model model) {
        List<Product_scrap> product_scrapList = scrapService.queryAll();
        model.addAttribute("scrapList", product_scrapList);
        return "/stock/scrapRecord";
    }

    @RequestMapping("/queryScrapByDate")
    public String queryScrapByDate(@RequestParam("date") String date, Model model) {
        List<Product_scrap> product_scrapList = new ArrayList<>();
        Product_scrap product_scrap = scrapService.queryByDate(date);
        System.out.println("-----------------");
        System.out.println(product_scrap);
        product_scrapList.add(product_scrap);
        model.addAttribute("scrapList", product_scrapList);
        return "/stock/scrapRecord";
    }


}
